home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / ddj9304.zip / WAVELET.ZIP / DRAWIMAG.S < prev    next >
Text File  |  1992-02-07  |  11KB  |  199 lines

  1. #include "dsp_type.h"
  2. #if DSP32
  3. #include "dspregs.h"
  4. #endif
  5.  
  6. .global DRAWIMAG
  7.         /*  DRAWIMAG
  8.             draw image of supplied point and connect to previous point
  9.             registers used: r1 r2 r3 r4 r5 r6 r7 r12 r13 r14
  10.             accumulators used: a0 a1
  11.  
  12.             input: r12 - pointer to data pointer array
  13.                    r13 - pointer to stack
  14.                    r14 - return stack register, i.e. "TOP OF STACK"
  15.                    a0 - data point to draw
  16.         */
  17. DRAWIMAG: a0 = *r12++ - a0 * *r12++; /* multiply by scalling coefficient */
  18.           a1 = -a0 + *r12;    /* determine if value above upper threshold */
  19.           a0 = ifalt(*r12++); /* if true, limit data to threshold */
  20.           a1 = a0 - *r12;     /* determine if value below lower threshold */
  21.           a0 = ifalt(*r12++); /* if true, limit data to threshold */
  22.           *r12++ = a0 = int(a0); /* convert data to integer format */
  23.           nop;
  24.           r6e = r12 - 2;        /* point to temporary storage */
  25.           r1 = *r12++;          /* load the row increment value */
  26.           r4 = *r12++;          /* load the row baseline offset value */
  27.           r2 = *r12++;          /* load the bit pointer */
  28.           r3e = *r12;           /* load the byte column pointer */
  29.           r6 = *r6;             /* read the new byte column pointer offset */
  30.           r2 - 0x80;            /* check if first bit of new byte column */
  31.           if (ne) goto ADD_BAR; /* if true, add new bar to byte column */
  32.           nop;
  33. #if DSP32C
  34.           r6 - 23;               /* check if datum point is above baseline */
  35.           if (le) goto ABOVE_BL; /* if true, it is above the baseline */
  36.           nop;
  37.           r4 = 25;       /* top counter for clearing of pixel over bar */
  38.           r5 = r6 - 24;  /* middle counter for draw of bar pixels */
  39.           goto DRAW_COL; /* go draw the column of pixels */
  40.           r6 = 48 - r6;  /* bottom counter for clearing of pixel under bar */
  41.  
  42. ABOVE_BL: r4 = r6;      /* top counter for clearing of pixel over bar */
  43.           r5 = r6;
  44.           r5 = 24 - r5; /* middle counter for draw of bar pixels */
  45.           r6 = 25;      /* bottom counter for clearing of pixel under bar */
  46. DRAW_COL: r4 = r4 - 1;  /* check if no top pixels are to be cleared */
  47.           if (lt) goto NO_TOP; /* if true, skip clearing bytes above bar */
  48.           r7 = r7 - r7;        /* force the register to zero */
  49.           do 0, r4;            /* repeat next instruntion r4+1 times */
  50.           *r3++r1 = r7l;       /* zero the bytes above the bar */
  51. NO_TOP:   r5 = r5 - 1;         /* check if no bar pixels are to be set */
  52.           if (lt) goto NO_MID; /* if true, skip setting bytes of bar */
  53.           nop;
  54.           do 0, r5;         /* repeat next instruntion r5+1 times */
  55.           *r3++r1 = r2l;    /* MSB of byte is bar, others cleared */
  56. NO_MID:   r6 = r6 - 1;      /* check if no bottom pixels are to be cleared */
  57.           if (lt) goto NO_BOT; /* if true, skip clearing bytes below bar */
  58.           nop;
  59.           do 0, r6;            /* repeat next instruntion r6+1 times */
  60.           *r3++r1 = r7l;       /* zero the bytes below the bar */
  61. NO_BOT:   goto SHIFTBIT; /* go shift the bit pointer and clear up */
  62.           r3e = *r12;    /* reload the byte pointer */
  63.  
  64. ADD_BAR:  r6 - 24;              /* check if datum below baseline */
  65.           if (gt) goto BELOW_BL; /* if true, datum is below baseline */
  66.           r6 = r6 - 24;  /* calculate length of bar */
  67.           r6 = -r6;      /* datum above baseline length was negative */
  68.           r1e = -r1;     /* datum above baseline, increment is decrement */
  69. BELOW_BL: r4e = r4 + r3; /* add baseline offset to byte column pointer */
  70.           r5e = r4 + r1; /* move pointer away from the baseline */
  71.           r7 = 0;        /* zero initial storage value */
  72.           do 2, r6;      /* repeat the next 3 instructions r6+1 times */
  73.           r6l = *r5++r1; /* load the byte */
  74.           *r4++r1 = r7l; /* store the byte and move the pointer */
  75.           r7 = r6 | r2;  /* OR byte with bit pointer to set the bit */
  76. #else
  77.           r6 = r6 * 2;     /* multiply offset by four to account for ... */
  78.           r6 = r6 * 2;     /* four bytes per instruction in MEMSET */
  79.           r6 - 92;         /* check if datum point is above baseline */
  80.           if (le) goto ABOVE_BL; /* if true, it is above the baseline */
  81.           r5 = -r6;      /* middle counter for draw of bar pixels */
  82.           r4 = 0;        /* top counter for clearing of pixel over bar */
  83.           r5 = r5 + 196; /* middle counter for draw of bar pixels */
  84.           goto DRAW_COL; /* go draw the column of pixels */
  85.           r6 = r6 - 92;  /* bottom counter for clearing of pixel under bar */
  86.  
  87. ABOVE_BL: r4 = -r6;      /* top counter for clearing of pixel over bar */
  88.           r4 = r4 + 100; /* top counter for clearing of pixel over bar */
  89.           r5 = r6 + 4;   /* middle counter for draw of bar pixels */
  90.           r6 = 0;        /* bottom counter for clearing of pixel under bar */
  91. DRAW_COL: *r13-- = r14;  /* save return address to the stack */
  92.           call r4+MEMSET (r14); /* zero the bytes above the bar */
  93.           r7 = r7 - r7;         /* force the register to zero */
  94.           call r5+MEMSET (r14); /* set the bytes of the bar */
  95.           r7 = r2;              /* MSB of byte is bar, others cleared */
  96.           call r6+MEMSET (r14); /* zero the bytes below the bar */
  97.           r7 = r7 - r7;         /* force the register to zero */
  98.           r13 = r13 + 2;        /* point to return address on the stack */
  99.           r14 = *r13;           /* load the return address from the stack */
  100. NO_BOT:   goto SHIFTBIT; /* go shift the bit pointer and clear up */
  101.           r3 = *r12;     /* reload the byte pointer */
  102.  
  103. ADD_BAR:  r6 = r6 * 2;   /* multiply offset by twelve to account for ... */
  104.           r6 = r6 * 2;   /* four bytes per instruction and ... */
  105.           r7 = r6 * 2;   /* three instructions per byte in MEM_OR */
  106.           r6 = r6 + r7;
  107.           r6 - 288;               /* check if datum below baseline */
  108.           if (gt) goto BELOW_BL; /* if true, datum is below baseline */
  109.           r6 = r6 - 288; /* calculate length of bar */
  110.           r6 = -r6;      /* datum above baseline length was negative */
  111.           r1 = -r1;      /* datum above baseline, increment is decrement */
  112. BELOW_BL: r6 = 288 - r6  /* align the counter for proper call */
  113.           r4 = r4 + r3;  /* add baseline offset to byte column pointer */
  114.           r5 = r4;
  115.           r5 = r5 + r1;  /* move pointer away from the baseline */
  116.           *r13-- = r14;  /* save return address to the stack */
  117.           r7 = 0;        /* zero initial storage value */
  118.           call r6+MEM_OR (r14);
  119.           r6 = r7;
  120.           r13 = r13 + 2;        /* point to return address on the stack */
  121.           r14 = *r13;           /* load the return address from the stack */
  122. #endif
  123.  
  124. SHIFTBIT: r2 = r2 >> 1;    /* shift the pixel pointed to right */
  125.           if (ne) goto NO_WRAP; /* if true, don't wrap the pixel pointer */
  126.           r12e = r12 - 2;  /* point to bit pointer storage */
  127.           r2 = 0x0080;     /* new bit mask if pixel wraps */
  128.           r3e = r3 + 1;    /* increment base to next byte upon wrap */
  129. NO_WRAP:  *r12++ = r2;     /* save the next bit pointer */
  130.           return (r14);
  131.           *r12++ = r3e;    /* save the next byte pointer start value */
  132.         /* END OF DRAWIMAG */
  133.  
  134. #if DSP32
  135.         /*  MEMSET
  136.             set column of image bytes to a given value
  137.             registers used: r1 r3 r7 r14
  138.  
  139.             input: r1 - postincrement value
  140.                    r3 - byte column pointer
  141.                    r7 - storage value
  142.                    r14 - return stack register, i.e. "TOP OF STACK"
  143.         */
  144. MEMSET:   *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;
  145.           *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;
  146.           *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;
  147.           *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;
  148.           *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;
  149.           *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;  *r3++r1 = r7l;
  150.           *r3++r1 = r7l;
  151.  
  152.           return (r14);
  153.           nop;
  154.         /* END OF MEMSET */
  155.  
  156.         /*  MEM_OR
  157.             logical OR column of image bytes with a given value
  158.             registers used: r1 r4 r5 r6 r7 r14
  159.  
  160.             input: r1 - postincrement value
  161.                    r2 - 'OR' value
  162.                    r4 - lagging byte column pointer
  163.                    r5 - leading byte column pointer
  164.                    r14 - return stack register, i.e. "TOP OF STACK"
  165.         */
  166. MEM_OR:   r6l = *r5++r1;  /* load column byte */
  167.           *r4++r1 = r7l;  /* save initial 'dummy' value */
  168.           r6 = r6 | r2;   /* 'OR' column byte with byte value */
  169.           r7l = *r5++r1;  /* load the next column byte */
  170.           *r4++r1 = r6l;  /* save the new column byte value */
  171.           r7 = r7 | r2;   /* 'OR' the next column byte with the byte value */
  172.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  173.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  174.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  175.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  176.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  177.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  178.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  179.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  180.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  181.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  182.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  183.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  184.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  185.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  186.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  187.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  188.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  189.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  190.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  191.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  192.           r6l = *r5++r1;  *r4++r1 = r7l;  r6 = r6 | r2;
  193.           r7l = *r5++r1;  *r4++r1 = r6l;  r7 = r7 | r2;
  194.           r6l = *r5++r1;  *r4++r1 = r7l;
  195.           return (r14);
  196.           nop;
  197.         /* END OF MEMSET */
  198. #endif
  199.